<%@ page language="java" import="com.oreilly.servlet.MultipartRequest,com.demo.util.Conn" pageEncoding="UTF-8"%>
<%
if ("post".equals(request.getMethod().toLowerCase())) {
	String basePath = request.getRealPath("/") + "student_pic/";
	int maxSize = 1024 * 1024;
	MultipartRequest multi = new MultipartRequest(request , basePath , maxSize, "UTF-8");
	String fileName = multi.getFilesystemName("picFile");
	String user_id = session.getAttribute("user_id").toString();
	String sql = "update dbf_stuuser set pic_file='" + fileName + "' where STUUSER_ID=" + user_id;
	new Conn().update(sql);
	
	response.sendRedirect("baseinfo.jsp");
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Upload picture</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<link rel="stylesheet" type="text/css" href="../style.css">
  </head>
  
  <body>
  <table width="718" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="39" colspan="3" background="../images/main_title.jpg"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span class="menutitle">Upload My Picture </span></strong></td>
    </tr>
    <tr>
      <td valign="bottom"><img src="../images/menu_a.jpg" width="19" height="23" /></td>
      <td valign="top">&nbsp;</td>
      <td valign="bottom"><img src="../images/menu_b.jpg" width="18" height="23" /></td>
    </tr>
    <tr>
      <td width="19" valign="top" background="../images/menu_c.jpg"><img src="../images/menu_c.jpg" width="19" height="54" /></td>
      <td width="681" valign="top"><form action="uploadPic.jsp" enctype="multipart/form-data" method="post">
	  	<table border="0" align="center" cellpadding="0" cellspacing="0" class="logintxt">
	  		<tr><td height="50" colspan="2">&nbsp;</td></tr>
	  		<tr>
	  			<td width="50%" align="right">Select Image ：</td>
	  			<td width="50%" align="left"><input type="file" name="picFile" size="20" /></td>
	  		</tr>
	  		<tr><td colspan="2">&nbsp;</td></tr>
	  		<tr><td align="center" colspan="2"><input name="image" type="image" value="upload" src="../images/upload_btn.jpg" /></td></tr>
	    </table>
    </form></td>
      <td width="18" valign="top" background="../images/menu_d.jpg"><img src="../images/menu_d.jpg" width="18" height="54" /></td>
    </tr>
    <tr>
      <td><img src="../images/menu_e.jpg" width="19" height="25" /></td>
      <td background="../images/menu_f.jpg"><img src="../images/menu_f.jpg" width="181" height="25" /></td>
      <td><img src="../images/menu_g.jpg" width="18" height="25" /></td>
    </tr>
  </table>
  </body>
</html>
